Skip to contentSkip to conversation

add test servers to use with t_client.sh

PATCH In review Jens Neuhalfen 1 participant 2 messages Apr 23, 2016 – Apr 29, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 add test servers to use with t_client.sh

Hi,

this patch will add test servers to use with t_client.sh. This will make testing on different systems much easier. Bonus: testing on a laptop is a breeze.

Virtual machines are defined by [Vagrant](https://www.vagrantup.com) scripts. Virtualbox is used for virtualisation.

Each of the virtual machines is configured to compile openvpn and run a server.

Inside the vm a openvpn server can be launched to run t_client.sh tests against it. Sample launcher scripts are provided.

Patch as attachment because of its size.

Jens

From 49e38594839526e9185d8f0250d781ab43b39348 Mon Sep 17 00:00:00 2001
From: Jens Neuhalfen <[email protected]...>
Date: Fri, 22 Apr 2016 17:37:43 +0200
Subject: [PATCH 1/2] add test servers to use with t_client.sh

Virtual machines defined by [Vagrant](https://www.vagrantup.com) scripts. Virtualbox is used for virtualisation.

Each of the virtual machines is configured to compile openvpn and run a server.

Inside the vm a openvpn server can be launched to run t_client.sh tests against it. Sample launcher scripts are provided.

---
 tests/server/.gitignore                          |  1 +
 tests/server/README.md                           | 45 ++++++++++++
 tests/server/scripts/compile.sh                  |  8 +++
 tests/server/scripts/start_server.sh             | 88 ++++++++++++++++++++++++
 tests/server/scripts/sync_codebase.sh            |  6 ++
 tests/server/ubuntu_precise64/README.md          |  9 +++
 tests/server/ubuntu_precise64/Vagrantfile        | 37 ++++++++++
 tests/server/ubuntu_precise64/launch_t_client.sh |  4 ++
 tests/server/ubuntu_trusty64/README.md           |  9 +++
 tests/server/ubuntu_trusty64/Vagrantfile         | 37 ++++++++++
 tests/server/ubuntu_trusty64/launch_t_client.sh  |  4 ++
 tests/t_client.rc-sample                         | 27 ++++++--
 12 files changed, 271 insertions(+), 4 deletions(-)
 create mode 100644 tests/server/.gitignore
 create mode 100644 tests/server/README.md
 create mode 100755 tests/server/scripts/compile.sh
 create mode 100755 tests/server/scripts/start_server.sh
 create mode 100755 tests/server/scripts/sync_codebase.sh
 create mode 100644 tests/server/ubuntu_precise64/README.md
 create mode 100644 tests/server/ubuntu_precise64/Vagrantfile
 create mode 100755 tests/server/ubuntu_precise64/launch_t_client.sh
 create mode 100644 tests/server/ubuntu_trusty64/README.md
 create mode 100644 tests/server/ubuntu_trusty64/Vagrantfile
 create mode 100755 tests/server/ubuntu_trusty64/launch_t_client.sh
tests/server/.gitignore new file +1 -0
new file mode 100644
index 0000000..a977916
@@ -0,0 +1 @@
+.vagrant/
tests/server/README.md new file +45 -0

45 lines not on this page · raw message

tests/server/scripts/compile.sh new file +8 -0
new file mode 100755
index 0000000..32e00a7
@@ -0,0 +1,8 @@
+# -*- mode: sh -*-
+# vi: set ft=sh :
+#!/bin/sh
+
+cd ~/openvpn
+./configure
+make clean
+make -j3
tests/server/scripts/start_server.sh new file +88 -0

88 lines not on this page · raw message

tests/server/scripts/sync_codebase.sh new file +6 -0
new file mode 100755
index 0000000..c4ec27a
@@ -0,0 +1,6 @@
+# -*- mode: sh -*-
+# vi: set ft=sh :
+#!/bin/sh
+
+cd ~
+rsync -avd --no-o /openvpn .
tests/server/ubuntu_precise64/README.md new file +9 -0
new file mode 100644
index 0000000..0c48d60
@@ -0,0 +1,9 @@
+OpenVPN testserver
+====================
+
+| VM Definition                        |
+|------------|-------------------------|
+| **Distro** | Ubuntu Precise Pangolin |
+| **Arch**   | x86_64                  |
+| **IPv4**   | 192.168.33.66           |
+| **IPv6**   | N/A                     |
tests/server/ubuntu_precise64/Vagrantfile new file +37 -0
new file mode 100644
index 0000000..11f3b22
@@ -0,0 +1,37 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+
+Vagrant.configure(2) do |config|
+  config.vm.box = "hashicorp/precise64"
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  #
+  # This IP is used in  t_client.rc (REMOTE_IP). Make sure that both are
+  # the same, if you want to use this Vagrant VM
+  config.vm.network "private_network", ip: "192.168.33.67", netmask: "24"
+
+  # Mount the source root under /openvpn.
+  # TODO: mount read-only
+  config.vm.synced_folder "../../..", "/openvpn"
+  config.vm.synced_folder "../scripts", "/scripts"
+
+  config.vm.provider "virtualbox" do |vb|
+     vb.memory = 1024
+     # for compiling; only works in 64 bit VMs
+     vb.cpus = 2
+     # Faster imports
+     vb.linked_clone = true if Vagrant::VERSION =~ /^1.8/
+  end
+
+   config.vm.provision "shell", inline: <<-SHELL
+
+sudo apt-get update
+sudo apt-get install  -y autoconf g++ make liblzo2-dev libpam0g-dev openssl
+
+echo '/scripts/sync_codebase.sh && /scripts/compile.sh && sudo /scripts/start_server.sh' > ~vagrant/compile_and_run.sh
+chmod 755 ~vagrant/compile_and_run.sh
+chown vagrant:vagrant ~vagrant/compile_and_run.sh
+SHELL
+end
tests/server/ubuntu_precise64/launch_t_client.sh new file +4 -0
new file mode 100755
index 0000000..ed9a09d
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd ../..
+REMOTE_IP=192.168.33.67 ./t_client.sh
tests/server/ubuntu_trusty64/README.md new file +9 -0
new file mode 100644
index 0000000..111373f
@@ -0,0 +1,9 @@
+OpenVPN testserver
+====================
+
+| VM Definition                      |
+|------------|-----------------------|
+| **Distro** | Ubuntu Trusty Tahr    |
+| **Arch**   | x86_64                |
+| **IPv4**   | 192.168.33.66         |
+| **IPv6**   | N/A                   |
tests/server/ubuntu_trusty64/Vagrantfile new file +37 -0
new file mode 100644
index 0000000..57f0232
@@ -0,0 +1,37 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+
+Vagrant.configure(2) do |config|
+  config.vm.box = "ubuntu/trusty64"
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  #
+  # This IP is used in  t_client.rc (REMOTE_IP). Make sure that both are
+  # the same, if you want to use this Vagrant VM
+  config.vm.network "private_network", ip: "192.168.33.66", netmask: "24"
+
+  # Mount the source root under /openvpn.
+  # TODO: mount read-only
+  config.vm.synced_folder "../../..", "/openvpn"
+  config.vm.synced_folder "../scripts", "/scripts"
+
+  config.vm.provider "virtualbox" do |vb|
+     vb.memory = 1024
+     # for compiling; only works in 64 bit VMs
+     vb.cpus = 2
+     # Faster imports
+     vb.linked_clone = true if Vagrant::VERSION =~ /^1.8/
+  end
+
+   config.vm.provision "shell", inline: <<-SHELL
+
+sudo apt-get update
+sudo apt-get install  -y autoconf g++ make liblzo2-dev libpam0g-dev libssl-dev libtool
+
+echo '/scripts/sync_codebase.sh && /scripts/compile.sh && sudo /scripts/start_server.sh' > ~vagrant/compile_and_run.sh
+chmod 755 ~vagrant/compile_and_run.sh
+chown vagrant:vagrant ~vagrant/compile_and_run.sh
+SHELL
+end
tests/server/ubuntu_trusty64/launch_t_client.sh new file +4 -0
new file mode 100755
index 0000000..4996478
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd ../..
+REMOTE_IP=192.168.33.66 ./t_client.sh
tests/t_client.rc-sample +23 -4
index 6e66607..ef6035f 100644
@@ -4,6 +4,9 @@
 #
 # (sample config, copy to t_client.rc and adapt to your environment)
 #
+# This script is also sourced by the example OpenVPN servers (Vagrant files).
+#
+# The example servers can be run for instant remote endpoints for t_client.sh
 #
 # define these - if empty, no tests will run
 #
@@ -12,9 +15,25 @@ CA_CERT="${top_srcdir}/sample/sample-keys/ca.crt"
 CLIENT_KEY="${top_srcdir}/sample/sample-keys/client.key"
 CLIENT_CERT="${top_srcdir}/sample/sample-keys/client.crt"
 #
-# remote host (used as macro below)
+# Configuration for the test server started via vagrant
+#
+VM_SERVER_KEY="${top_srcdir}/sample/sample-keys/server.key"
+VM_SERVER_CERT="${top_srcdir}/sample/sample-keys/server.crt"
+VM_SERVER_DH="${top_srcdir}/sample/sample-keys//dh2048.pem"
+
+#
+VM_SERVER_IP="10.8.0.1"
+# Passed as --server $VM_SERVER_NET $VM_SERVER_MASK
+VM_SERVER_NET="10.8.0.0"
+VM_SERVER_MASK="255.255.255.0"
+
 #
-REMOTE=mytestserver
+# remote host (used as macro below and for the test server in the vm)
+# When the test server (Vagrant) is used, make sure that
+# the IP  equals the IP in Vagrantfile
+REMOTE_IP="192.168.33.67"
+REMOTE_PORT="51194"
+
 #
 # tests to run (list suffixes for config stanzas below)
 #
@@ -57,7 +76,7 @@ OPENVPN_BASE_P2P="..."
 #   specify IPv4+IPv6 addresses expected from server and ping targets
 #
 RUN_TITLE_1="testing tun/udp/ipv4+ipv6"
-OPENVPN_CONF_1="$OPENVPN_BASE_P2MP --dev tun --proto udp --remote $REMOTE --port 51194"
+OPENVPN_CONF_1="$OPENVPN_BASE_P2MP --dev tun --proto udp --remote ${REMOTE_IP} --port ${REMOTE_PORT}"
 EXPECT_IFCONFIG4_1="10.100.50.6"
 EXPECT_IFCONFIG6_1="2001:db8:a050::1:0"
 PING4_HOSTS_1="10.100.50.1 10.100.0.1"
@@ -66,7 +85,7 @@ PING6_HOSTS_1="2001:db8::1 2001:db8:a050::1"
 # Test 2: TCP / p2mp tun
 #
 RUN_TITLE_2="testing tun/tcp/ipv4+ipv6"
-OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194"
+OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote ${REMOTE_IP} --port ${REMOTE_PORT}"
 EXPECT_IFCONFIG4_2="10.100.51.6"
 EXPECT_IFCONFIG6_2="2001:db8:a051::1:0"
 PING4_HOSTS_2="10.100.51.1 10.100.0.1"
Signature · 1 line
2.6.4 (Apple Git-63)
#1 lore raw

Hi everyone,

I reworked the scripts, and put them in a PR for comments: https://github.com/OpenVPN/openvpn/pull/45 <https://github.com/OpenVPN/openvpn/pull/45>

cheers
Jens

Quoted 18 lines · Jens Neuhalfen

Hi,

this patch will add test servers to use with t_client.sh. This will make testing on different systems much easier. Bonus: testing on a laptop is a breeze.

Virtual machines are defined by [Vagrant](https://www.vagrantup.com) scripts. Virtualbox is used for virtualisation.

Each of the virtual machines is configured to compile openvpn and run a server.

Inside the vm a openvpn server can be launched to run t_client.sh tests against it. Sample launcher scripts are provided.

Patch as attachment because of its size.

Jens <0001-add-test-servers-to-use-with-t_client.sh.patch>